home *** CD-ROM | disk | FTP | other *** search
- /*
- File: OutputFontData.c
-
- Contains: QuickDraw GX to PostScript conversion code.
- File contains functions which is responsible
- for outputting and encoding fonts at all levels of the
- document.
-
- Version: Technology: Quickdraw GX 1.1.x
-
- Copyright: © 1991-1997 by Apple Computer, Inc., all rights reserved.
- */
-
- #include "GXToPSBuildConfig.h"
- #include "IOUtilities.h"
- #include <GXExceptions.h>
- #include "GXPrintingUniverse.h"
- #include "FontHandler.h"
- #include "FontHandlerPrivate.h"
- #include "FontHandlerVariations.h"
- #include <String.h>
- #include "FHResources.h"
-
-
- #ifdef resumeLabel
- #undef resumeLabel
- #endif
- #define resumeLabel(exception)
-
- #ifdef encodingsDontTakeFFFF
- /**********************
- Temporary routine: Remove in when works in TT (I hope q160).
-
- Sets all of the 0xffff entries in an encoding to be zero
-
- ***********************/
- void ResetSentinalValues(unsigned short *encoding)
- {
- long i;
- for (i = 0; i < 256; ++i) {
- if (encoding[i] == 0xFFFF)
- encoding[i] = 0;
- }
- }
- #endif
-
- /********************************************
-
- Function: FontHandlerOutputVariationPSOperator
-
- This function calls GX to output the postscript font
- variation operator for the font and style in question.
-
- **********************************************/
- OSErr FontHandlerOutputVariationPSOperator(TFontHandlerContext context, gxStyle theStyle)
- {
- OSErr status;
- long count;
- gxFontVariation *variations;
- Handle h;
- scalerStream streamRecord;
-
-
- /** Count the number of axes in the style vectoring through the font handler **/
-
- status = _FontHandlerGetStyleFontVariations(context, theStyle, &count, nil);
- nrequire(status, failed_Count);
-
- if (count > 0) {
-
- /** Actually get the variations **/
-
- status = FHSetWorkHandleSize((TFontHandlerHdl)context,
- count * sizeof(gxFontVariation),
- 0, &h);
- nrequire(status, failed_SetSize);
-
- HLockHi(h);
- variations = (gxFontVariation*)*h;
-
- status = _FontHandlerGetStyleFontVariations(context, theStyle, &count, variations);
- nrequire(status, failed_GetVariations);
-
- /** Now stream the variation PostScript operator **/
-
- streamRecord.types = (*(TFontHandlerHdl)context)->legalStreamTypes;
- streamRecord.targetVersion = (*(TFontHandlerHdl)context)->productDescription;
- streamRecord.action = variationPSOperatorStreamAction;
- streamRecord.variationCount = count;
- streamRecord.variations = variations;
-
- // DL 7/27/97: This used to use the GX message, now we use the psDevice method.
- status = (*(TFontHandlerHdl)context)->psDevice->StreamFont(FHgxGetStyleFont(theStyle), &streamRecord);
- ncheck(status);
-
-
- failed_GetVariations:
-
- FHReleaseWorkspace((TFontHandlerHdl)context, 0);
-
- }//end if
-
- failed_SetSize:
- failed_Count:
-
- return(status);
-
- }//FontHandlerOutputVariationPSOperator
-
-
-
- //<FF>
- /********************************************
-
- Function: FHDownloadEncoding:
-
- Function streams an encoding for a printer resident
- font based on the printer font record specified. The encoding is
- left on the operand stack.
-
- printerFont: Pointer to The printer font record.
- legalTypes: Legal types for streaming.
- productDescription: Product description string.
-
- *********************************************/
- OSErr FHDownloadEncoding(CGXtoPostScriptDevice *psDevice, TPrinterFontRec *printerFont, scalerStreamTypeFlag legalTypes, char *productDescription);
- OSErr FHDownloadEncoding(CGXtoPostScriptDevice *psDevice, TPrinterFontRec *printerFont, scalerStreamTypeFlag legalTypes, char *productDescription)
- {
- OSErr status;
- scalerStream streamRecord;
- unsigned long *glyphBits; // Make copy of glyph bits because streaming can corrupt them.
-
- /** Copy the glyph usage data **/
-
- status = PrNewPtr((Ptr *) &glyphBits, printerFont->usageSize);
- nrequire(status, failed_Alloc);
- memcpy(glyphBits, printerFont->glyphUsage, printerFont->usageSize);
-
- #ifdef encodingsDontTakeFFFF
- ResetSentinalValues(printerFont->printerFontCodes);
- #endif
-
- streamRecord.types = legalTypes;
- streamRecord.targetVersion = productDescription;
- streamRecord.action = encodingOnlyStreamAction;
- streamRecord.variationCount = 0;
- streamRecord.variations = nil;
- streamRecord.info.font.encoding = printerFont->printerFontCodes;
- streamRecord.info.font.glyphBits = (long*)glyphBits;
- streamRecord.info.font.name = nil;
-
- // DL 3/27/97: Used to use the GX message, now we use the device method.
- status = psDevice->StreamFont(printerFont->theRealFont, &streamRecord);
- nrequire(status, failed_StreamFont);
-
- printerFont->info |= fontIsEncoded;
-
- failed_StreamFont:
-
- DisposePtr((Ptr)glyphBits);
-
- failed_Alloc:
-
- return(status);
-
- }//FHDownloadEncoding
-
-
-
- //<FF>
- /********************************************
-
- Function: FHDownloadFont:
-
- Function streams a font to the printer
- based on printer font record specified.
- Only the glyphs used by the printer font are
- downloaded.
-
- docDbase: Document font database. Used to retrieve variations from.
- printerFont: Pointer to The printer font record.
- legalTypes: Legal types for streaming.
- productDescription: Product description string.
-
- *********************************************/
- OSErr FHDownloadFont(TFontHandlerPtr pFHRec, TPrinterFontRec *printerFont, scalerStreamTypeFlag legalTypes, char *productDescription)
- {
- OSErr status;
- TFontDbase docDbase = pFHRec->docDbase;
- scalerStream streamRecord;
- unsigned char name[256];
- long nameLen;
- unsigned long *glyphBits; // Make copy of glyph bits because streaming can corrupt them.
- gxFontVariation *theVariations;
- Boolean lockedDbase = false;
-
- /** Copy the glyph usage data **/
-
- status = PrNewPtr((Ptr *) &glyphBits, printerFont->usageSize);
- nrequire(status, failed_Alloc);
- memcpy(glyphBits, printerFont->glyphUsage, printerFont->usageSize);
-
- nameLen = FHGeneratePrinterName(printerFont, name);
- check(nameLen);
-
- #ifdef encodingsDontTakeFFFF
- ResetSentinalValues(printerFont->printerFontCodes);
- #endif
- streamRecord.types = legalTypes;
- streamRecord.targetVersion = productDescription;
- if (pFHRec->asciiDownload)
- streamRecord.action = asciiDownloadStreamAction;
- else
- streamRecord.action = downloadStreamAction;
- streamRecord.info.font.encoding = printerFont->printerFontCodes;
- streamRecord.info.font.glyphBits = (long*)glyphBits;
- streamRecord.info.font.name = (char*)name;
-
- /** Set up the variations fields in the stream record. eMainBits implies don't need snapshots **/
-
- if (printerFont->dbIndex == eMainBits) {
-
- streamRecord.variationCount = selectAllVariations;
- streamRecord.variations = nil;
-
- } else {
-
- status = FontDbaseLock(docDbase);
- nrequire(status, failed_Lock);
-
- lockedDbase = true;
-
- status = FontDbaseGetGlyphBits(docDbase, printerFont->theRealFont, printerFont->dbIndex, nil, &theVariations);
- nrequire(status, failed_GetVariations);
-
- streamRecord.variationCount = GXCountFontVariations(printerFont->theRealFont);
- streamRecord.variations = theVariations;
-
- }//end if
-
- // DL 7/27/97: Used to use gx message, now we use device method.
- status = pFHRec->psDevice->StreamFont(printerFont->theRealFont, &streamRecord);
- nrequire(status, failed_StreamFont);
-
- /* Mark font ready for use */
-
- printerFont->info |= (fontIsEncoded + fontIsDownloaded);
-
- failed_StreamFont:
- failed_GetVariations:
-
- if (lockedDbase) {
-
- OSErr saveStatus = FontDbaseUnlock(docDbase);
- if (status == noErr)
- status = saveStatus;
-
- ncheck(saveStatus);
-
- }//end if
-
- failed_Lock:
-
- DisposePtr((Ptr)glyphBits);
-
- failed_Alloc:
- return(status);
-
- }//FHDownloadFont
-
- //<FF>
- /********************************************
- Function: FHDownloadFontAllDocGlyphs
-
- Function downloads the font specified by the encoding
- in the printer font record. The font will contain
- all non-resident glyphs required by the document including
- the ones encoded by this particular printer-font. Thus
- all subsequent printer fonts for the specified doc font
- can just be re-encodings of this one thereby saving
- memory.
-
- pFHRec: pointer to font handler record.
- printerFont: The printer font specification.
-
- **********************************************/
- OSErr FHDownloadFontAllDocGlyphs(TFontHandlerHdl hFHRec, TPrinterFontRec *printerFont);
- OSErr FHDownloadFontAllDocGlyphs(TFontHandlerHdl hFHRec, TPrinterFontRec *printerFont)
- {
- OSErr status;
- long size;
- register short i;
- scalerStream streamRecord;
- Handle h;
- unsigned long *docGlyphBits;
- unsigned long *docMinusPrinterBits;
- unsigned long *pNewBits, *pDocBits, *pResidentBits;
- gxPrinterGlyphsRec *fontLocation; // A printer glyph location.
- unsigned char name[256];
- long nameLen;
- long nGlyphs;
- gxFontVariation *theVariations;
- Boolean lockedDbase = false;
-
- nameLen = FHGeneratePrinterName(printerFont, name);
- check(nameLen);
-
- /** Allocate space for a new bit array **/
-
- size = printerFont->usageSize; // This is the right size for all glyph bits.
-
- /* Allocate a handle for the new bits and the Printer-Glyphs record. */
-
- status = FHSetWorkHandleSize(hFHRec, 2 * size + sizeof(gxPrinterGlyphsRec) - sizeof (unsigned long) , 1, &h);
- nrequire(status, failed_SetSize);
-
- HLockHi(h);
- docMinusPrinterBits = (unsigned long*)*h;
- fontLocation = (gxPrinterGlyphsRec*)(*h + size);
-
- /** Get the bits used for the document **/
-
- nrequire(status = FontDbaseLock((*hFHRec)->docDbase), failed_Lock);
-
- status = FontDbaseGetFontInfo((*hFHRec)->docDbase, printerFont->theRealFont, &nGlyphs, nil, nil, nil);
- nrequire(status, failed_GetInfo);
-
- status = FontDbaseGetGlyphBits((*hFHRec)->docDbase, printerFont->theRealFont, printerFont->dbIndex, &docGlyphBits, nil);
- nrequire(status, failed_GetDocBits);
-
- /** Get the bits for resident glyphs **/
-
- memset(fontLocation->glyphBits, 0, size); // clear it so message can set bits for glyph usage.
- fontLocation->theFont = printerFont->theRealFont;
- fontLocation->nGlyphs = nGlyphs;
- status = (*hFHRec)->psDevice->GetPrinterGlyphsInformation(fontLocation); // DL 7/27/97: Used to use GX message.
- nrequire(status, failed_GetFontGlyphs);
-
- /*** Compute a new bit array that is the document glyphs excluding the printer-resident glyphs ***/
-
- pDocBits = docGlyphBits;
- pResidentBits = fontLocation->glyphBits;
- pNewBits = docMinusPrinterBits;
- for (i = (printerFont->usageSize / 4) - 1; i >= 0; --i)
- *pNewBits++ = *pDocBits++ & ~*pResidentBits++;
-
-
- /** Now Download the font **/
-
- #ifdef encodingsDontTakeFFFF
- ResetSentinalValues(printerFont->printerFontCodes);
- #endif
- streamRecord.types = (*hFHRec)->legalStreamTypes;
- streamRecord.targetVersion = (*hFHRec)->productDescription;
- if ((*hFHRec)->asciiDownload)
- streamRecord.action = asciiDownloadStreamAction;
- else
- streamRecord.action = downloadStreamAction;
- streamRecord.info.font.encoding = printerFont->printerFontCodes;
- streamRecord.info.font.name = (char*)name;
- streamRecord.info.font.glyphBits = (long*)docMinusPrinterBits;
-
- /** Set up the variations fields in the stream record. eMainBits implies don't need snapshots **/
-
- if (printerFont->dbIndex == eMainBits) {
-
- streamRecord.variationCount = selectAllVariations;
- streamRecord.variations = nil;
-
- } else {
-
- status = FontDbaseGetGlyphBits((*hFHRec)->docDbase, printerFont->theRealFont,
- printerFont->dbIndex, nil, &theVariations);
- nrequire(status, failed_GetVariations);
-
- streamRecord.variationCount = GXCountFontVariations(printerFont->theRealFont);
- streamRecord.variations = theVariations;
-
- }//end if
-
- // DL 7/27/97: Used to use GX message, now we use device method.
- status = (*hFHRec)->psDevice->StreamFont(printerFont->theRealFont, &streamRecord);
- nrequire(status, failed_Stream);
-
- /* Mark font as ready for use */
-
- printerFont->info |= (fontIsEncoded + fontIsDownloaded);
-
- failed_Stream:
- failed_GetVariations:
- failed_GetFontGlyphs:
- failed_GetDocBits:
- failed_GetInfo:
-
- {
- register OSErr saveStatus;
- saveStatus = FontDbaseUnlock((*hFHRec)->docDbase);
- ncheck(saveStatus);
- if (saveStatus != noErr)
- status = saveStatus;
- }
-
- failed_Lock:
-
- FHReleaseWorkspace(hFHRec, 1);
-
- failed_SetSize:
-
- return(status);
-
- }//FHDownloadFontAllDocGlyphs
-
-
- //<FF>
- /********************************************
-
- Function: FHReEncodeFont
-
- Function generates a new font that is re-encoding
- of another font that is either printer resident or
- previously downloaded.
-
- pFHRec: Pointer to font handler handle (Handle assumed locked).
- printerFont: The printer font to make encoding for.
- printerFontToEncode: Printer font record to re-encode. If nil then re-encode the resident font.
-
- *********************************************/
- OSErr FHReEncodeFont(TFontHandlerPtr pFHRec, TPrinterFontRec *printerFont, TPrinterFontRec *printerFontToEncode)
- {
- OSErr status;
- short nameLen;
- unsigned char name[256];
- TRDParams rdParams;
-
- rdParams.rdMap = pFHRec->rdMap;
- rdParams.resType = kScriptResType;
- rdParams.resID = kFHScriptResID;
- rdParams.rdFlags = eRDnoOptions;
-
- if (printerFont->info & fontCantBeRencoded) {
-
- /************************
- Basically, do nothing, printer resident composite fonts cannot be reencoded
- but it is easier to let the main code that calls this routine
- not have to know the difference, since it is called to
- for printer-resident fonts.
-
- Issue a "findfont" on this font since it may be a disk based font, we'd
- like to get it loaded into "fontdirectory" outside of the page save/restore
- because "findfont" can be really slow if the font dictionary is not in VM.
-
- Seems to only be problem on old NTX-J's but we'll do it all of the time
- becuase it is cheap enough to not special case.
- *************************/
-
- nameLen = FHGetFontName(printerFont->theRealFont, printerFont->nameIndex, nil, nil, nil, nil, name);
-
- rdParams.resIndex = kFindFontPop;
- nrequire(status = RDResPrintf(&rdParams, name, nameLen), failed_ResPrintf);
-
- } else {
-
-
- /** Put name of encoded font on stack - this will be name to be used to get this encoding **/
-
- nameLen = FHGeneratePrinterName(printerFont, name);
- rdParams.resIndex = kFontName;
- nrequire(status = RDResPrintf(&rdParams, name, nameLen), failed_ResPrintf);
-
- /* Put the Boolean for fixing SEAC on the stack - only do for printer resident fonts */
-
- rdParams.resIndex = kBoolean;
- if (printerFont->info & fontIsInPrinter)
- status = RDResPrintf(&rdParams, "true", 4);
- else
- status = RDResPrintf(&rdParams, "false", 5);
- nrequire(status, failed_ResPrintf);
-
- /* Stream the encoding vector onto the operand stack. */
-
- status = FHDownloadEncoding(pFHRec->psDevice, printerFont, pFHRec->legalStreamTypes, pFHRec->productDescription);
- nrequire(status, failed_DownloadEncoding);
-
- /* Get the name of the font to re-encode on the operand stack */
-
- if (printerFontToEncode == nil)
- /* Put the PostScript name on the stack */
- nameLen = FHGetFontName(printerFont->theRealFont, printerFont->nameIndex, nil, nil, nil, nil, name);
- else
- /* Put the name of printer-font at of the index specified on the stack */
- nameLen = FHGeneratePrinterName(printerFontToEncode, name);
-
- rdParams.resIndex = kFontName;
- nrequire(status = RDResPrintf(&rdParams, name, nameLen), failed_ResPrintf);
-
- /* Execute the procedure to make the encoded font */
-
- rdParams.resIndex = kReEncodeFont;
- nrequire(status = RDResPrintf(&rdParams), failed_ResPrintf);
-
- }//end if
-
- printerFont->info |= fontIsEncoded; // font on printer is ready to use.
-
-
- failed_ResPrintf:
- failed_DownloadEncoding:
-
- return(status);
-
- }//FHReEncodeFont
-
- //<FF>
- /********************************************
-
- Function: FHDoDocumentPermFonts
-
- Function makes all fonts that will be perminant
- at the document level available on the printer.
- For fonts with resident glyphs, a new encoding
- is generated. For non-resident fonts, they are
- downloaded with the proper encoding.
-
- **********************************************/
- OSErr FHDoDocumentPermFonts(TFontHandlerHdl hFHRec);
- OSErr FHDoDocumentPermFonts(TFontHandlerHdl hFHRec)
- {
- OSErr status;
- TFontHandlerPtr pFHRec;
- TPrinterFontRec *printerFont, *printerFontToReEncode;
- long i, j, nPrFonts, nDocFonts;
- TFontDbase fontDbase;
- fhFont theFont;
- #if DEBUGLEVEL > 1
- TRDParams rdParams;
- rdParams.rdMap = (*hFHRec)->rdMap;
- rdParams.resType = kScriptResType;
- rdParams.resID = kFHScriptResID;
- rdParams.rdFlags = eRDnoOptions;
- #endif
-
- HLockHi((Handle)hFHRec); // Lock it so all of our glyph usage bits are locked
- pFHRec = *hFHRec; // Because streaming could move memory.
-
- fontDbase = pFHRec->docDbase;
-
- status = FontDbaseCountFonts(fontDbase, &nDocFonts);
- nrequire(status, failed_CountFonts);
-
- nDocFonts = FHCountSnapshots(hFHRec);
-
-
- /**********************************************
- For each document font, download any encodings
- for printer-resident glyphs, and download any
- doc-level (permanent) printer-fonts and encodings
- ***********************************************/
-
- for (i = 1; i <= nDocFonts; ++i) {
-
- status = FHGetIndexedSnapshot(hFHRec, i, &theFont);
- nrequire(status, failed_GetFont);
-
- /** go through each printer font for the document font **/
-
- nPrFonts = FHCountPrinterFonts(hFHRec, theFont);
- for (j = 0; j < nPrFonts; ++j) {
-
- status = FHGetIndexedPrinterFont(hFHRec, theFont, j, &printerFont, nil);
- nrequire(status, failed_GetPrinterFont);
-
- /** Do the appropriate thing with the printer font **/
-
- if (printerFont->info & fontIsInPrinter) {
-
- /** Re-encode the printer-resident font **/
-
- status = FHReEncodeFont(pFHRec, printerFont, nil);
- nrequire(status, failed_ReEncodeResident);
- pFHRec->vmAvailable -= kEncodingOverhead;
-
- #if DEBUGLEVEL > 1
- rdParams.resIndex = kDebugShowVM;
- status = RDResPrintf(&rdParams, kEncodingOverhead);
- nrequire(status, failed_ResPrintf);
- #endif
-
- } else if (printerFont->info & fontIsPerm) {
-
- if (printerFont->info & fontHasAllDocGlyphs) {
-
- /******
- This Printer font will contain all downloaded glyphs with encoding it specifies,
- The reamining printer fonts for this doc font will just be re-encodings
- *******/
-
- printerFontToReEncode = printerFont; // save reference for remaining printer-fonts.
-
- status = FHDownloadFontAllDocGlyphs(hFHRec, printerFont);
- nrequire(status, failed_AllGlyphs);
- pFHRec->vmAvailable -= printerFont->docVMUsage;
-
- #if DEBUGLEVEL > 1
- rdParams.resIndex = kDebugShowVM;
- status = RDResPrintf(&rdParams, printerFont->docVMUsage);
- nrequire(status, failed_ResPrintf);
- #endif
-
- } else if (printerFont->info & fontIsEncodingOnly) {
-
- /** Make encoding for first printer font that has all document glyphs **/
-
- status = FHReEncodeFont(pFHRec, printerFont, printerFontToReEncode);
- nrequire(status, failed_ReEncodePrinterFont);
- pFHRec->vmAvailable -= kEncodingOverhead;
-
- #if DEBUGLEVEL > 1
- rdParams.resIndex = kDebugShowVM;
- status = RDResPrintf(&rdParams, kEncodingOverhead);
- nrequire(status, failed_ResPrintf);
- #endif
-
- } else {
-
- /** Download the printer-font as an independant entity **/
-
- status = FHDownloadFont(pFHRec, printerFont, pFHRec->legalStreamTypes, pFHRec->productDescription);
- nrequire(status, failed_Download);
- pFHRec->vmAvailable -= printerFont->vmUsage;
-
- #if DEBUGLEVEL > 1
- rdParams.resIndex = kDebugShowVM;
- status = RDResPrintf(&rdParams, printerFont->vmUsage);
- nrequire(status, failed_ResPrintf);
- #endif
-
- }//end if
-
- }//end if
-
-
- /** Output a PostScript comment to display the font reference **/
- #if DEBUGLEVEL > 1
- rdParams.resIndex = kDebugFontRef;
- status = RDResPrintf(&rdParams, &(printerFont->theRealFont), 4);
- nrequire(status, failed_ResPrintf);
- #endif
-
- }//end for
-
- /** Make a two-byte font if possible for the document font **/
-
- status = FHMakeTwoByteFont(hFHRec, theFont);
- nrequire(status, failed_MakeTwoByte);
-
- }//end for
-
- #if DEBUGLEVEL > 1
- rdParams.resIndex = kDebugShowVMTotal;
- status = RDResPrintf(&rdParams, pFHRec->printerVM - pFHRec->vmAvailable);
- nrequire(status, failed_ResPrintf);
-
- rdParams.resIndex = kDebugShowVMLeft;
- status = RDResPrintf(&rdParams, pFHRec->vmAvailable);
- nrequire(status, failed_ResPrintf);
- #endif
-
- failed_MakeTwoByte:
- failed_ResPrintf:
- failed_Download:
- failed_ReEncodePrinterFont:
- failed_AllGlyphs:
- failed_ReEncodeResident:
- failed_GetPrinterFont:
- failed_GetFont:
- failed_CountFonts:
-
-
- HUnlock((Handle)hFHRec);
-
- return(status);
-
- }//FHDoDocumentPermFonts
-
- /********************************************
-
- Function: FHDoPrerequisites
-
- Function computes and downloads necessary prerequisite
- data for the fonts in the document.
-
-
- **********************************************/
- OSErr FHDoPrerequisites(TFontHandlerHdl hFHRec);
- OSErr FHDoPrerequisites(TFontHandlerHdl hFHRec)
- {
- OSErr status;
- TFontHandlerPtr pFHRec;
- TFontDbase fontDbase;
- long prereqCount; // Number of required prerequisites.
- long prereqVM; // This will be the total VM required by all prerequisites.
- long idx;
- gxFont theFont; // The font to pass into streaming.
- unsigned char prereqData[256 + sizeof(scalerPrerequisiteItem)]; // name is pascal string.
- scalerPrerequisiteItem *prereqItem = (scalerPrerequisiteItem*)prereqData; // point item at local data.
- scalerStream streamRecord;
- TRDParams rdParams;
-
- pFHRec = *hFHRec;
- fontDbase = pFHRec->docDbase;
-
- streamRecord.types = pFHRec->legalStreamTypes;
- streamRecord.targetVersion = pFHRec->productDescription;
- streamRecord.action = prerequisiteItemStreamAction;
- streamRecord.variationCount = 0;
- streamRecord.variations = nil;
-
- rdParams.rdMap = pFHRec->rdMap;
- rdParams.resType = kScriptResType;
- rdParams.resID = kFHScriptResID;
- rdParams.rdFlags = eRDnoOptions;
-
-
- status = FontDbaseBuildPrerequisiteList(fontDbase, pFHRec->legalStreamTypes,
- pFHRec->productDescription, true, &prereqCount);
- nrequire(status, failed_buildList);
-
- /*** Loop through the prerequisites and download them, updating avaialable VM ***/
-
- prereqVM = 0;
- for (idx = 1; idx <= prereqCount; ++idx) {
-
- status = FontDbaseGetIndexedPrerequisite(fontDbase, idx, nil, &theFont, prereqItem);
- nrequire(status, failed_GetPrereq);
-
- pFHRec = *hFHRec;
- prereqVM += prereqItem->size; // update amount used.
- pFHRec->vmAvailable -= prereqItem->size; // update amount available.
-
- /** Abort job if no printer memory is avilable **/
-
- require_action(pFHRec->vmAvailable > 0, failed_noRoomForItem, status = -9999;);
-
- /** Emit a %%BeginResource comment **/
-
- rdParams.resIndex = kBeginResource;
- status = RDResPrintf(&rdParams, prereqItem->name);
- nrequire(status, failed_beginResource);
-
- /** Stream the item **/
-
- streamRecord.info.prerequisiteItem = prereqItem->enumeration;
- status = (*hFHRec)->psDevice->StreamFont(theFont, &streamRecord); // DL 7/27/97: Used to use GX message.
- nrequire(status, failed_stream);
-
- /** Emit a vm usage comment **/
-
- rdParams.resIndex = kDebugShowVM;
- status = RDResPrintf(&rdParams, prereqItem->size);
- nrequire(status, failed_vmComment);
-
- /** Emit an %%EndResource comment **/
-
- rdParams.resIndex = kEndResource;
- status = RDResPrintf(&rdParams);
- nrequire(status, failed_EndResource);
-
- }//end for
-
- failed_EndResource:
- failed_vmComment:
- failed_stream:
- failed_beginResource:
- failed_noRoomForItem:
- failed_GetPrereq:
- failed_buildList:
- return(status);
-
- }//FHDoPrerequisites
-
-
-
-
- //<FF>
- /********************************************
-
- Function: FontHandlerDoDocumentHeader
-
- This function outputs any necessary font
- data for the document header. This inlucdes
- all document fonts and encodings.
-
- *********************************************/
- OSErr FontHandlerDoDocumentHeader(TFontHandlerContext context)
- {
- OSErr status;
- TRDParams rdParams;
-
- /** Only do anything if there are any fonts in the document **/
-
- if (FHCountSnapshots((TFontHandlerHdl)context) > 0) {
-
- /** Put font handler dictionary on the dictionary stack **/
-
- rdParams.rdMap = (*(TFontHandlerHdl)context)->rdMap;
- rdParams.resType = kScriptResType;
- rdParams.resID = kFHScriptResID;
- rdParams.rdFlags = eRDnoOptions;
-
- rdParams.resIndex = kFHDictOnStack;
- nrequire(status = RDResPrintf(&rdParams), failed_ResPrintf);
-
-
- /** Compute the doc-level (permanent) and page-level fonts **/
-
- status = FHFindDocLevelFonts((TFontHandlerHdl)context);
- nrequire(status, failed_DocLevelFonts);
-
- /** Compute and download the required prerequisites **/
-
- status = FHDoPrerequisites((TFontHandlerHdl)context);
- nrequire(status, failed_prerequisites);
-
- /** Download the document level fonts **/
-
- status = FHDoDocumentPermFonts((TFontHandlerHdl)context);
- nrequire(status, failed_PermFonts);
-
- /** Take the font handler dictionary off the dictionary stack **/
-
- rdParams.resIndex = kFHDictOffStack;
- nrequire(status = RDResPrintf(&rdParams), failed_ResPrintf2);
-
- } else {
-
- status = noErr;
-
- }//end if
-
-
- failed_ResPrintf2:
- failed_PermFonts:
- failed_prerequisites:
- failed_DocLevelFonts:
- failed_ResPrintf:
-
-
- return(status);
-
- }//FontHandlerDoDocumentHeader
-
-